package com.bree.erp.jsf.view.pr;

import java.io.Serializable;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;


//import org.apache.log4j.Logger;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.LazyDataModel;

import com.bree.erp.entity.Project;
import com.bree.erp.entity.PurchaseRequisition;
import com.bree.erp.service.ProjectService;
import com.bree.erp.service.PurchaseRequisitionService;

//@ManagedBean(name = "dtPurchaseRequisitionLazyView")
//@ViewScoped
public abstract class AbstractPurchaseRequisitionLazyView implements Serializable {

	private static final long serialVersionUID = 1L;

	//private static Logger LOG = Logger.getLogger(AbstractPurchaseRequisitionLazyView.class);

	@EJB
	protected ProjectService projectService;
	@EJB
	protected PurchaseRequisitionService purchaseRequisitionService;
	
	private PurchaseRequisition selectedItem;
	

	public void onRowSelect(SelectEvent event) {
		FacesMessage msg = new FacesMessage("Item Selected",
				((PurchaseRequisition) event.getObject()).getId() + "");
		FacesContext.getCurrentInstance().addMessage(null, msg);
	}

	
	public List<Project> getProjects() {
		return projectService.list();
	}
	/**
	 * @return the selectedItem
	 */
	public PurchaseRequisition getSelectedItem() {
		return selectedItem;
	}

	/**
	 * @param selectedItem the selectedItem to set
	 */
	public void setSelectedItem(PurchaseRequisition selectedItem) {
		this.selectedItem = selectedItem;
	}
	/**
	 * @return the lazyModel
	 */
	public abstract LazyDataModel<PurchaseRequisition> getLazyModel();
}
